package com.gisocn.onemap.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import butterknife.internal.Utils;
import com.bumptech.glide.Glide;
import com.gisocn.onemap.interfaces.OnItemClickListener;
import com.gisocn.onemap.interfaces.OnItemDeleteListener;
import com.gisocn.onemap.interfaces.OnItemLongClickListener;
import com.gisocn.onemap.model.FileCenter;
import com.gisocn.onemap.sgzx.R;
import com.gisocn.onemap.utils.FileUtils;
import java.util.ArrayList;

/* loaded from: classes2.dex */
public class FilePackageAdapter extends RecyclerView.Adapter<ViewHolder> {
    private Context context;
    private ArrayList<FileCenter> fileCenterList;
    private OnItemClickListener onItemClickListener = null;
    private OnItemDeleteListener onItemDeleteListener = null;
    private OnItemLongClickListener onItemLongClickListener = null;
    private int type;

    /* loaded from: classes2.dex */
    public class ViewHolder_ViewBinding implements Unbinder {
        private ViewHolder target;

        public ViewHolder_ViewBinding(ViewHolder viewHolder, View view) {
            this.target = viewHolder;
            viewHolder.ivType = (ImageView) Utils.findRequiredViewAsType(view, R.id.iv_type, "field 'ivType'", ImageView.class);
            viewHolder.ivdel = (ImageView) Utils.findRequiredViewAsType(view, R.id.iv_del, "field 'ivdel'", ImageView.class);
            viewHolder.tvFileName = (TextView) Utils.findRequiredViewAsType(view, R.id.tv_file_name, "field 'tvFileName'", TextView.class);
            viewHolder.tvFileNameSzie = (TextView) Utils.findRequiredViewAsType(view, R.id.tv_file_name_szie, "field 'tvFileNameSzie'", TextView.class);
            viewHolder.rlDownload = (RelativeLayout) Utils.findRequiredViewAsType(view, R.id.rl_download, "field 'rlDownload'", RelativeLayout.class);
            viewHolder.ivThumbnail = (ImageView) Utils.findRequiredViewAsType(view, R.id.iv_thumbnail, "field 'ivThumbnail'", ImageView.class);
            viewHolder.ivDownloadBg = (ImageView) Utils.findRequiredViewAsType(view, R.id.iv_download_bg, "field 'ivDownloadBg'", ImageView.class);
            viewHolder.ivDownload = (ImageView) Utils.findRequiredViewAsType(view, R.id.iv_download, "field 'ivDownload'", ImageView.class);
        }

        @Override // butterknife.Unbinder
        public void unbind() {
            ViewHolder viewHolder = this.target;
            if (viewHolder == null) {
                throw new IllegalStateException("Bindings already cleared.");
            }
            this.target = null;
            viewHolder.ivType = null;
            viewHolder.ivdel = null;
            viewHolder.tvFileName = null;
            viewHolder.tvFileNameSzie = null;
            viewHolder.rlDownload = null;
            viewHolder.ivThumbnail = null;
            viewHolder.ivDownloadBg = null;
            viewHolder.ivDownload = null;
        }
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    public FilePackageAdapter(ArrayList<FileCenter> arrayList, Context context, int i) {
        this.fileCenterList = arrayList;
        this.context = context;
        this.type = i;
    }

    public void setOnItemDeleteListener(OnItemDeleteListener onItemDeleteListener) {
        this.onItemDeleteListener = onItemDeleteListener;
    }

    public void setOnItemLongClickListener(OnItemLongClickListener onItemLongClickListener) {
        this.onItemLongClickListener = onItemLongClickListener;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        return new ViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_file_package, viewGroup, false));
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public void onBindViewHolder(ViewHolder viewHolder, final int i) {
        viewHolder.tvFileNameSzie.setText(this.fileCenterList.get(i).getName());
        if (this.fileCenterList.get(i).getType() == 1) {
            viewHolder.ivType.setVisibility(0);
            viewHolder.ivType.setImageResource(R.mipmap.icon_file_package);
            viewHolder.rlDownload.setVisibility(8);
        }
        if (this.fileCenterList.get(i).getType() == 0) {
            if (FileUtils.isLocalExistPath(this.fileCenterList.get(i).getHerf(), this.context)) {
                viewHolder.ivType.setVisibility(0);
                viewHolder.rlDownload.setVisibility(8);
                if (this.fileCenterList.get(i).getName().contains(".pdf")) {
                    viewHolder.ivType.setImageResource(R.mipmap.icon_pdf);
                } else if (this.fileCenterList.get(i).getName().contains(".ppt")) {
                    viewHolder.ivType.setImageResource(R.mipmap.icon_ppt);
                } else if (this.fileCenterList.get(i).getName().contains(".doc")) {
                    viewHolder.ivType.setImageResource(R.mipmap.icon_docx);
                } else if (this.fileCenterList.get(i).getName().contains(".xls")) {
                    viewHolder.ivType.setImageResource(R.mipmap.icon_excel);
                } else {
                    Glide.with(this.context).load(this.fileCenterList.get(i).getHerf()).thumbnail(0.1f).into(viewHolder.ivType);
                }
            } else {
                viewHolder.ivType.setVisibility(8);
                viewHolder.rlDownload.setVisibility(0);
            }
        }
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() { // from class: com.gisocn.onemap.ui.adapter.FilePackageAdapter.1
            @Override // android.view.View.OnClickListener
            public void onClick(View view) {
                if (FilePackageAdapter.this.onItemClickListener != null) {
                    FilePackageAdapter.this.onItemClickListener.onItemClick(view, i);
                }
            }
        });
        viewHolder.itemView.setOnLongClickListener(new View.OnLongClickListener() { // from class: com.gisocn.onemap.ui.adapter.FilePackageAdapter.2
            @Override // android.view.View.OnLongClickListener
            public boolean onLongClick(View view) {
                if (FilePackageAdapter.this.onItemLongClickListener != null) {
                    FilePackageAdapter.this.onItemLongClickListener.onItemClick(view, i);
                    return true;
                }
                return true;
            }
        });
        viewHolder.ivdel.setOnClickListener(new View.OnClickListener() { // from class: com.gisocn.onemap.ui.adapter.FilePackageAdapter.3
            @Override // android.view.View.OnClickListener
            public void onClick(View view) {
                if (FilePackageAdapter.this.onItemDeleteListener != null) {
                    FilePackageAdapter.this.onItemDeleteListener.onItemDelete(view, i);
                }
            }
        });
        viewHolder.ivdel.setVisibility(this.fileCenterList.get(i).isDelete() ? 0 : 8);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public int getItemCount() {
        return this.fileCenterList.size();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes2.dex */
    public static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.iv_download)
        ImageView ivDownload;
        @BindView(R.id.iv_download_bg)
        ImageView ivDownloadBg;
        @BindView(R.id.iv_thumbnail)
        ImageView ivThumbnail;
        @BindView(R.id.iv_type)
        ImageView ivType;
        @BindView(R.id.iv_del)
        ImageView ivdel;
        @BindView(R.id.rl_download)
        RelativeLayout rlDownload;
        @BindView(R.id.tv_file_name)
        TextView tvFileName;
        @BindView(R.id.tv_file_name_szie)
        TextView tvFileNameSzie;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
